import java.awt.image.BufferedImage;

public abstract class FlyingObject {
    protected int x;
    protected int y;                //位置
    protected int imageWidth;
    protected int imageHeight;      //图片大小
    protected int health;           //生命值
    protected BufferedImage image;  //生成图片
    protected boolean remove;       //判断消失

    FlyingObject() {
    }

    FlyingObject(int x, int y, int imageWidth, int imageHeight, int health, BufferedImage image, boolean remove) {
        this.x = x;
        this.y = y;
        this.imageWidth = imageWidth;
        this.imageHeight = imageHeight;
        this.health = health;
        this.image = image;
        this.remove = remove;
    }

    abstract void move();

    //击中判定
    public boolean hit(Bullet bullet) {
        int x = bullet.x;
        int y = bullet.y;

        return x > this.x && x < this.x + this.imageWidth &&
                y > this.y && y < this.y + this.imageHeight;
    }
    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getImageWidth() {
        return imageWidth;
    }

    public void setImageWidth(int imageWidth) {
        this.imageWidth = imageWidth;
    }

    public int getImageHeight() {
        return imageHeight;
    }

    public void setImageHeight(int imageHeight) {
        this.imageHeight = imageHeight;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }

    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    public boolean isRemove() {
        return remove;
    }

    public void setRemove(boolean remove) {
        this.remove = remove;
    }
}
